const express = require('express')
const carousel_handle = require('../router_handle/carousel.js')
const multer  = require('multer')
const path = require('path')

const storage = multer.diskStorage({
  destination: (req, file, cb)=> { cb(null, 'static/images/carousel') },
  filename: (req, file, cb)=> { cb(null, Date.now() + path.extname(file.originalname)) }
})

const upload = multer({ storage })

const router = express.Router();

router.post('/upload',upload.single('file'), carousel_handle.upload);

router.post('/add', carousel_handle.add);

router.get('/list', carousel_handle.list);

router.get('/detail', carousel_handle.detail);

router.post('/search', carousel_handle.search);

router.delete('/delete', carousel_handle.delete);

router.post('/update', carousel_handle.update);

router.post('/toggle', carousel_handle.toggle);

module.exports = router